home *** CD-ROM | disk | FTP | other *** search
- /* TrackSetText.c */
- /*
- * Copyright © 1989 Martin Minow. All rights reserved.
- *
- * TrackSetText(text, length, track_handle)
- * text Data to insert
- * length The number of bytes to insert
- * track_handle The TrackRecord handle
- *
- * Copy the specified text into the TrackRecord. Any
- * text currently in the TrackRecord is lost. The
- * selection range is set to an insertion point at the
- * end of the text. (Note: TextEdit TESetText "doesn't
- * dispose of any text currently in the edit record.")
- * The text origin is reset to "upper-left" corner.
- *
- */
- #include "TrackEdit.h"
- #define TR (*tr)
-
- void
- TrackSetText(text, length, track_handle)
- Ptr text;
- LONGINT length;
- TrackHandle track_handle;
- {
- register TrackPtr tr;
- _Track_state state;
- Boolean track_was_active;
-
- /*
- * Dump the selection, stuff the text, then
- * recreate the selection.
- */
- track_was_active =
- _Track_is_set((*track_handle), _Track_is_active);
- if (track_was_active)
- TrackDeactivate(track_handle);
- tr = _Track_lock(track_handle, &state);
- SetHandleSize(TR.hText, length);
- BlockMove(text, *TR.hText, length);
- TR.selStart = TR.selEnd = length;
- TR.textLength = length;
- TR.topPixel = 0;
- TR.leftPixel = 0;
- _Track_rebuild(track_handle, 0L);
- _Track_unlock(&state);
- if (track_was_active)
- TrackActivate(track_handle);
- }
-
-